package com.mass.core.sys.dict.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mass.core.sys.dict.dao.SysDictTypeMapper;
import com.mass.core.sys.dict.model.SysDictType;
import com.mass.core.sys.dict.service.SysDictTypeService;

import java.util.List;

/**

 * annotation:SysDictType  业务层实现类
 * created by pannan on 2017/08/25
 * 
 */
@Service
public class SysDictTypeServiceImpl implements SysDictTypeService {

    @Autowired
    private SysDictTypeMapper sysDictTypeMapper;

    /**
     * 根据ID查询数据信息.
     *
     * @param id                查询条件
     * @return
     */
    public SysDictType getEntityById(Long id) {
        return this.sysDictTypeMapper.getEntityById(id);
    }

    /**
     * 添加数据词典类型
     *  @param sysDictType
     *  @return
     */
    public SysDictType addEntity(SysDictType sysDictType) {
        return 0 < this.sysDictTypeMapper.insert(sysDictType) ? sysDictType : null;
    }
    /**
     * 修改数据词典类型
     * @param sysDictType
     * */
    public boolean editEntity(SysDictType sysDictType) {
        return 0 < this.sysDictTypeMapper.update(sysDictType);
    }
    /**
     * 删除数据词典类型
     *  @param id
     * */
    public boolean deleteEntity(Long id) {
        return 0 < this.sysDictTypeMapper.delete(id);
    }

    /**
     *验证编码唯一
     *@param typeCode  编码
     **/
    public boolean checkTypeCodeIsExist(String typeCode) {
        SysDictType sysDictType= this.sysDictTypeMapper.getByTypeCode(typeCode);
        return null == sysDictType;
    }

    /**
     *查询全部词典类型
     **/
    public List<SysDictType> selectAll() {
        return this.sysDictTypeMapper.selectAll();
    }
}
